package com.dsg.config;

import com.dsg.config.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 自定义拦截器配置
 */
@Configuration
public class InterceptorConfiguration implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;//登录验证拦截器

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //设置登录拦截器的优先级别
        InterceptorRegistration registration = registry.addInterceptor(this.loginInterceptor);
        registration.order(1);
        registration.addPathPatterns("/rest/**");
    }

}
